<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="服务商父ID" prop="agentPid">
        <el-input
          v-model="queryParams.agentPid"
          placeholder="请输入服务商父ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司名称" prop="agentName">
        <el-input
          v-model="queryParams.agentName"
          placeholder="请输入公司名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司简称" prop="shortName">
        <el-input
          v-model="queryParams.shortName"
          placeholder="请输入公司简称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="法人姓名" prop="legalName">
        <el-input
          v-model="queryParams.legalName"
          placeholder="请输入法人姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="营业执照号" prop="licenseNo">
        <el-input
          v-model="queryParams.licenseNo"
          placeholder="请输入营业执照号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司类型(1 企业 2 个体 3 自然人)" prop="agentType">
        <el-select v-model="queryParams.agentType" placeholder="请选择公司类型(1 企业 2 个体 3 自然人)" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="有无实体(1 实体 2 虚拟)" prop="isShop">
        <el-input
          v-model="queryParams.isShop"
          placeholder="请输入有无实体(1 实体 2 虚拟)"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="服务电话" prop="servicePhone">
        <el-input
          v-model="queryParams.servicePhone"
          placeholder="请输入服务电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="省" prop="provinceId">
        <el-input
          v-model="queryParams.provinceId"
          placeholder="请输入省"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="市" prop="cityId">
        <el-input
          v-model="queryParams.cityId"
          placeholder="请输入市"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区" prop="areaId">
        <el-input
          v-model="queryParams.areaId"
          placeholder="请输入区"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="公司详细地址" prop="address">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入公司详细地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属行业" prop="mcc">
        <el-input
          v-model="queryParams.mcc"
          placeholder="请输入所属行业"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="门头照" prop="doorPhoto">
        <el-input
          v-model="queryParams.doorPhoto"
          placeholder="请输入门头照"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="营业执照照片" prop="licensePhoto">
        <el-input
          v-model="queryParams.licensePhoto"
          placeholder="请输入营业执照照片"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="结算周期(1 月结 2 日结)" prop="settleType">
        <el-select v-model="queryParams.settleType" placeholder="请选择结算周期(1 月结 2 日结)" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="支付模型(1使用商户信息)" prop="paymentMode">
        <el-input
          v-model="queryParams.paymentMode"
          placeholder="请输入支付模型(1使用商户信息)"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="通知地址" prop="notifyUrl">
        <el-input
          v-model="queryParams.notifyUrl"
          placeholder="请输入通知地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="分账渠道" prop="benefitChannel">
        <el-input
          v-model="queryParams.benefitChannel"
          placeholder="请输入分账渠道"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="直属商户ID" prop="directMchtId">
        <el-input
          v-model="queryParams.directMchtId"
          placeholder="请输入直属商户ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人姓名" prop="contactName">
        <el-input
          v-model="queryParams.contactName"
          placeholder="请输入负责人姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人身份证号" prop="contactIdentityNo">
        <el-input
          v-model="queryParams.contactIdentityNo"
          placeholder="请输入负责人身份证号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人电话" prop="contactPhone">
        <el-input
          v-model="queryParams.contactPhone"
          placeholder="请输入负责人电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人邮箱" prop="contactEmail">
        <el-input
          v-model="queryParams.contactEmail"
          placeholder="请输入负责人邮箱"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证生效时间" prop="identityStartTime">
        <el-input
          v-model="queryParams.identityStartTime"
          placeholder="请输入身份证生效时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证失效时间" prop="identityEndTime">
        <el-input
          v-model="queryParams.identityEndTime"
          placeholder="请输入身份证失效时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证正面" prop="identityFrontPhoto">
        <el-input
          v-model="queryParams.identityFrontPhoto"
          placeholder="请输入身份证正面"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证背面" prop="identityBackPhoto">
        <el-input
          v-model="queryParams.identityBackPhoto"
          placeholder="请输入身份证背面"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手持证件照" prop="handlePhoto">
        <el-input
          v-model="queryParams.handlePhoto"
          placeholder="请输入手持证件照"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="服务商启用状态(0正常 1关闭)" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择服务商启用状态(0正常 1关闭)" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="进件状态 5注销 4冻结 3驳回 2进件中 1初始化 0进件成功" prop="entryStatus">
        <el-select v-model="queryParams.entryStatus" placeholder="请选择进件状态 5注销 4冻结 3驳回 2进件中 1初始化 0进件成功" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="服务商密钥" prop="agentKey">
        <el-input
          v-model="queryParams.agentKey"
          placeholder="请输入服务商密钥"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段1" prop="ext1">
        <el-input
          v-model="queryParams.ext1"
          placeholder="请输入预留字段1"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段2" prop="ext2">
        <el-input
          v-model="queryParams.ext2"
          placeholder="请输入预留字段2"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段3" prop="ext3">
        <el-input
          v-model="queryParams.ext3"
          placeholder="请输入预留字段3"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段4" prop="ext4">
        <el-input
          v-model="queryParams.ext4"
          placeholder="请输入预留字段4"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="预留字段5" prop="ext5">
        <el-input
          v-model="queryParams.ext5"
          placeholder="请输入预留字段5"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['agent:agentInfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['agent:agentInfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['agent:agentInfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['agent:agentInfo:export']"
        >导出</el-button>
      </el-col>
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="agentInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="服务商ID" align="center" prop="agentId" />
      <el-table-column label="服务商父ID" align="center" prop="agentPid" />
      <el-table-column label="公司名称" align="center" prop="agentName" />
      <el-table-column label="公司简称" align="center" prop="shortName" />
      <el-table-column label="法人姓名" align="center" prop="legalName" />
      <el-table-column label="营业执照号" align="center" prop="licenseNo" />
      <el-table-column label="公司类型(1 企业 2 个体 3 自然人)" align="center" prop="agentType" />
      <el-table-column label="有无实体(1 实体 2 虚拟)" align="center" prop="isShop" />
      <el-table-column label="服务电话" align="center" prop="servicePhone" />
      <el-table-column label="省" align="center" prop="provinceId" />
      <el-table-column label="市" align="center" prop="cityId" />
      <el-table-column label="区" align="center" prop="areaId" />
      <el-table-column label="公司详细地址" align="center" prop="address" />
      <el-table-column label="所属行业" align="center" prop="mcc" />
      <el-table-column label="门头照" align="center" prop="doorPhoto" />
      <el-table-column label="营业执照照片" align="center" prop="licensePhoto" />
      <el-table-column label="结算周期(1 月结 2 日结)" align="center" prop="settleType" />
      <el-table-column label="支付模型(1使用商户信息)" align="center" prop="paymentMode" />
      <el-table-column label="通知地址" align="center" prop="notifyUrl" />
      <el-table-column label="分账渠道" align="center" prop="benefitChannel" />
      <el-table-column label="直属商户ID" align="center" prop="directMchtId" />
      <el-table-column label="负责人姓名" align="center" prop="contactName" />
      <el-table-column label="负责人身份证号" align="center" prop="contactIdentityNo" />
      <el-table-column label="负责人电话" align="center" prop="contactPhone" />
      <el-table-column label="负责人邮箱" align="center" prop="contactEmail" />
      <el-table-column label="身份证生效时间" align="center" prop="identityStartTime" />
      <el-table-column label="身份证失效时间" align="center" prop="identityEndTime" />
      <el-table-column label="身份证正面" align="center" prop="identityFrontPhoto" />
      <el-table-column label="身份证背面" align="center" prop="identityBackPhoto" />
      <el-table-column label="手持证件照" align="center" prop="handlePhoto" />
      <el-table-column label="服务商启用状态(0正常 1关闭)" align="center" prop="status" />
      <el-table-column label="进件状态 5注销 4冻结 3驳回 2进件中 1初始化 0进件成功" align="center" prop="entryStatus" />
      <el-table-column label="服务商密钥" align="center" prop="agentKey" />
      <el-table-column label="预留字段1" align="center" prop="ext1" />
      <el-table-column label="预留字段2" align="center" prop="ext2" />
      <el-table-column label="预留字段3" align="center" prop="ext3" />
      <el-table-column label="预留字段4" align="center" prop="ext4" />
      <el-table-column label="预留字段5" align="center" prop="ext5" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['agent:agentInfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['agent:agentInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改服务商信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="服务商父ID" prop="agentPid">
          <el-input v-model="form.agentPid" placeholder="请输入服务商父ID" />
        </el-form-item>
        <el-form-item label="公司名称" prop="agentName">
          <el-input v-model="form.agentName" placeholder="请输入公司名称" />
        </el-form-item>
        <el-form-item label="公司简称" prop="shortName">
          <el-input v-model="form.shortName" placeholder="请输入公司简称" />
        </el-form-item>
        <el-form-item label="法人姓名" prop="legalName">
          <el-input v-model="form.legalName" placeholder="请输入法人姓名" />
        </el-form-item>
        <el-form-item label="营业执照号" prop="licenseNo">
          <el-input v-model="form.licenseNo" placeholder="请输入营业执照号" />
        </el-form-item>
        <el-form-item label="公司类型(1 企业 2 个体 3 自然人)" prop="agentType">
          <el-select v-model="form.agentType" placeholder="请选择公司类型(1 企业 2 个体 3 自然人)">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="有无实体(1 实体 2 虚拟)" prop="isShop">
          <el-input v-model="form.isShop" placeholder="请输入有无实体(1 实体 2 虚拟)" />
        </el-form-item>
        <el-form-item label="服务电话" prop="servicePhone">
          <el-input v-model="form.servicePhone" placeholder="请输入服务电话" />
        </el-form-item>
        <el-form-item label="省" prop="provinceId">
          <el-input v-model="form.provinceId" placeholder="请输入省" />
        </el-form-item>
        <el-form-item label="市" prop="cityId">
          <el-input v-model="form.cityId" placeholder="请输入市" />
        </el-form-item>
        <el-form-item label="区" prop="areaId">
          <el-input v-model="form.areaId" placeholder="请输入区" />
        </el-form-item>
        <el-form-item label="公司详细地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入公司详细地址" />
        </el-form-item>
        <el-form-item label="所属行业" prop="mcc">
          <el-input v-model="form.mcc" placeholder="请输入所属行业" />
        </el-form-item>
        <el-form-item label="门头照" prop="doorPhoto">
          <el-input v-model="form.doorPhoto" placeholder="请输入门头照" />
        </el-form-item>
        <el-form-item label="营业执照照片" prop="licensePhoto">
          <el-input v-model="form.licensePhoto" placeholder="请输入营业执照照片" />
        </el-form-item>
        <el-form-item label="结算周期(1 月结 2 日结)" prop="settleType">
          <el-select v-model="form.settleType" placeholder="请选择结算周期(1 月结 2 日结)">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="支付模型(1使用商户信息)" prop="paymentMode">
          <el-input v-model="form.paymentMode" placeholder="请输入支付模型(1使用商户信息)" />
        </el-form-item>
        <el-form-item label="通知地址" prop="notifyUrl">
          <el-input v-model="form.notifyUrl" placeholder="请输入通知地址" />
        </el-form-item>
        <el-form-item label="分账渠道" prop="benefitChannel">
          <el-input v-model="form.benefitChannel" placeholder="请输入分账渠道" />
        </el-form-item>
        <el-form-item label="直属商户ID" prop="directMchtId">
          <el-input v-model="form.directMchtId" placeholder="请输入直属商户ID" />
        </el-form-item>
        <el-form-item label="负责人姓名" prop="contactName">
          <el-input v-model="form.contactName" placeholder="请输入负责人姓名" />
        </el-form-item>
        <el-form-item label="负责人身份证号" prop="contactIdentityNo">
          <el-input v-model="form.contactIdentityNo" placeholder="请输入负责人身份证号" />
        </el-form-item>
        <el-form-item label="负责人电话" prop="contactPhone">
          <el-input v-model="form.contactPhone" placeholder="请输入负责人电话" />
        </el-form-item>
        <el-form-item label="负责人邮箱" prop="contactEmail">
          <el-input v-model="form.contactEmail" placeholder="请输入负责人邮箱" />
        </el-form-item>
        <el-form-item label="身份证生效时间" prop="identityStartTime">
          <el-input v-model="form.identityStartTime" placeholder="请输入身份证生效时间" />
        </el-form-item>
        <el-form-item label="身份证失效时间" prop="identityEndTime">
          <el-input v-model="form.identityEndTime" placeholder="请输入身份证失效时间" />
        </el-form-item>
        <el-form-item label="身份证正面" prop="identityFrontPhoto">
          <el-input v-model="form.identityFrontPhoto" placeholder="请输入身份证正面" />
        </el-form-item>
        <el-form-item label="身份证背面" prop="identityBackPhoto">
          <el-input v-model="form.identityBackPhoto" placeholder="请输入身份证背面" />
        </el-form-item>
        <el-form-item label="手持证件照" prop="handlePhoto">
          <el-input v-model="form.handlePhoto" placeholder="请输入手持证件照" />
        </el-form-item>
        <el-form-item label="服务商启用状态(0正常 1关闭)">
          <el-radio-group v-model="form.status">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="进件状态 5注销 4冻结 3驳回 2进件中 1初始化 0进件成功">
          <el-radio-group v-model="form.entryStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="服务商密钥" prop="agentKey">
          <el-input v-model="form.agentKey" placeholder="请输入服务商密钥" />
        </el-form-item>
        <el-form-item label="预留字段1" prop="ext1">
          <el-input v-model="form.ext1" placeholder="请输入预留字段1" />
        </el-form-item>
        <el-form-item label="预留字段2" prop="ext2">
          <el-input v-model="form.ext2" placeholder="请输入预留字段2" />
        </el-form-item>
        <el-form-item label="预留字段3" prop="ext3">
          <el-input v-model="form.ext3" placeholder="请输入预留字段3" />
        </el-form-item>
        <el-form-item label="预留字段4" prop="ext4">
          <el-input v-model="form.ext4" placeholder="请输入预留字段4" />
        </el-form-item>
        <el-form-item label="预留字段5" prop="ext5">
          <el-input v-model="form.ext5" placeholder="请输入预留字段5" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listAgentInfo, getAgentInfo, delAgentInfo, addAgentInfo, updateAgentInfo, exportAgentInfo } from "@/api/agent/agentInfo";

export default {
  name: "AgentInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 服务商信息表格数据
      agentInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        agentPid: null,
        agentName: null,
        shortName: null,
        legalName: null,
        licenseNo: null,
        agentType: null,
        isShop: null,
        servicePhone: null,
        provinceId: null,
        cityId: null,
        areaId: null,
        address: null,
        mcc: null,
        doorPhoto: null,
        licensePhoto: null,
        settleType: null,
        paymentMode: null,
        notifyUrl: null,
        benefitChannel: null,
        directMchtId: null,
        contactName: null,
        contactIdentityNo: null,
        contactPhone: null,
        contactEmail: null,
        identityStartTime: null,
        identityEndTime: null,
        identityFrontPhoto: null,
        identityBackPhoto: null,
        handlePhoto: null,
        status: null,
        entryStatus: null,
        agentKey: null,
        ext1: null,
        ext2: null,
        ext3: null,
        ext4: null,
        ext5: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询服务商信息列表 */
    getList() {
      this.loading = true;
      listAgentInfo(this.queryParams).then(response => {
        this.agentInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        agentId: null,
        agentPid: null,
        agentName: null,
        shortName: null,
        legalName: null,
        licenseNo: null,
        agentType: null,
        isShop: null,
        servicePhone: null,
        provinceId: null,
        cityId: null,
        areaId: null,
        address: null,
        mcc: null,
        doorPhoto: null,
        licensePhoto: null,
        settleType: null,
        paymentMode: null,
        notifyUrl: null,
        benefitChannel: null,
        directMchtId: null,
        contactName: null,
        contactIdentityNo: null,
        contactPhone: null,
        contactEmail: null,
        identityStartTime: null,
        identityEndTime: null,
        identityFrontPhoto: null,
        identityBackPhoto: null,
        handlePhoto: null,
        status: "0",
        entryStatus: "0",
        agentKey: null,
        ext1: null,
        ext2: null,
        ext3: null,
        ext4: null,
        ext5: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.agentId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加服务商信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const agentId = row.agentId || this.ids
      getAgentInfo(agentId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改服务商信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.agentId != null) {
            updateAgentInfo(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addAgentInfo(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const agentIds = row.agentId || this.ids;
      this.$confirm('是否确认删除服务商信息编号为"' + agentIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delAgentInfo(agentIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有服务商信息数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportAgentInfo(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    }
  }
};
</script>
